#define  _CRT_SECURE_NO_WARNINGS 1
#include"Date.h"
//bool Date::operator>(const Date& d) {
//
//
//
//}
//bool Date::operator<(const Date& d);
//bool Date::operator>=(const Date& d);
//bool Date::operator<=(const Date& d);
//bool Date::operator==(const Date& d);
//bool Date::operator!=(const Date& d);
Date::Date(int a, int b, int c) {
	_year = a;
	_month = b;
	_day = c;

}
int Date::GetDay(int year, int month) {
	static int arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };

	if (month == 2 && (year % 4 == 0 && year % 100 != 0 || year % 400 == 0))
	{
		return 29;
	}
	else
	{
		return arr[month];
	}
}
void Date::Print() {

	cout << _year << "-" << _month << "-" << _day<<endl;

}
Date& Date::operator+=(int n) {
	_day += n;
	while (_day > GetDay(_year, _month)) {
		_day -= GetDay(_year, _month);
		_month++;
		if (_month > 12){
			_year++;
			_month = 1;

		}


	}
	return *this;
}
Date Date::operator+(int n) {
	Date tmp = *this;
	tmp += n;
	return tmp;

}
Date& Date::operator-=(int n)
{
	_day -= n;
	while (_day < 1) {
		_month--;
		_day += GetDay(_year, _month);
		
		if (_month < 1) {
			_year--;
			_month = 12;

		}


	}
	return *this;
}
Date Date::operator-(int n) {
	Date tmp = *this;
	tmp -= n;
	return tmp;
}